﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace MyKTVUtils
{
    public  class DataSetUtiles
    {
        private static DataSet ds = new DataSet();
        public static  DataTable getTableByTableName(TableNameEnum name) {
            if (ds.Tables[name.ToString()] != null) {
                return ds.Tables[name.ToString()];
            }
            return null;
        }

        public static bool AddTable(DataTable table, TableNameEnum tableName) {
            if (ds.Tables[tableName.ToString()] != null)
            {
                table.TableName = tableName.ToString();
                ds.Tables.Add(table);
                return true;
            }
            return false;
        }


        public static bool RemoveDataTable(TableNameEnum tableName) {
            if (ds.Tables[tableName.ToString()] != null)
            {
                //如果包含 则按照表名删除表
                ds.Tables.Remove(tableName.ToString());
                return true;//返回true  删除成功
            }
            return false;

        }
    }
}
